package com.gxa.service.impl;

import com.gxa.domain.dto.CarInsuranceDTO;
import com.gxa.domain.dto.CarManageDTO;
import com.gxa.domain.entity.CarInsurance;
import com.gxa.domain.entity.CarManage;
import com.gxa.domain.vo.CarInsuranceVO;
import com.gxa.mapper.CarInsuranceMapper;
import com.gxa.mapper.CarManageMapper;
import com.gxa.service.CarInsuranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User: gxb
 * Date: 2024/07/17  10:24
 * Description:
 * Version: V1.0
 */
@Service//IOC注解  把当前service创建一个对象 交给spring进行管理
@Transactional//开启事务 事务是指逻辑上的一组要操作，要么都成功，要么都是失败
public class CarInsuranceServiceImpl implements CarInsuranceService {
    //di依赖注入  会从spring容器中获取drugMapper对象，然后进行设置
    @Autowired
    private CarInsuranceMapper carInsuranceMapper;

    @Override
    public void insertCarInsurance(CarInsurance carInsurance) {
        carInsuranceMapper.insertCarInsurance(carInsurance);
    }

    @Override
    public CarInsuranceVO findCarInsuranceById(Long id) {
        if(id==null){
            return null;
        }
        return carInsuranceMapper.findCarInsuranceById(id);
    }

    @Override
    public List<CarInsurance> findCarInsuranceAll() {
        return carInsuranceMapper.findCarInsuranceAll();
    }

    @Override
    public void updateCarInsurance(CarInsurance carInsurance) {
        carInsuranceMapper.updateCarInsurance(carInsurance);
    }

    @Override
    public void deleteCarInsuranceById(Long id) {
        if(id==null){
            return;
        }
        carInsuranceMapper.deleteCarInsuranceById(id);
    }

    @Override
    public List<CarInsurance> findCarInsuranceByWhere(CarInsuranceDTO carInsuranceDTO) {
        return carInsuranceMapper.findCarInsuranceByWhere(carInsuranceDTO);
    }
}
